package rs;

import java.io.*;
import java.util.*;
import rs.client.*;
import rs.items.*;
import javax.persistence.*;

@Entity
@Table(name = "Sale")
public class Sale implements Serializable {

	protected Client client;
	protected Item item;
	
	protected int saleId;
	
	/* Data em que a venda foi realizada */
	protected Date date;

	public Sale() {}
	
	public Sale(Client client, Item item) {
		this.client = client;
		this.item = item;
		this.date = new Date();
	}

	@ManyToOne(optional=false)
	@JoinColumn(name="my_clientid")
	public Client getClient() {
		return client;
	}

	public void setClient(Client client) {
		this.client = client;
	}

	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	@ManyToOne(optional=false)
	@JoinColumn(name="my_itemid")
	public Item getItem() {
		return item;
	}

	public void setItem(Item item) {
		this.item = item;
	}

	@Id
	@GeneratedValue
	public int getSaleId() {
		return saleId;
	}

	public void setSaleId(int saleId) {
		this.saleId = saleId;
	}
	
	public String toString(){
		return "[Sale: Date=" + date + "; item=" + item + "; client=" + client + "]";
	}
}
